package com.qj.yantaishan.common.config;

import cn.dev33.satoken.stp.StpInterface;
import com.qj.yantaishan.mapper.PermissionMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Collection;
import java.util.List;

/**
 * 自定义权限
 */
@Component
@Slf4j
public class PermissionConfig implements StpInterface {
    @Autowired
    private PermissionMapper permissionMapper;

    //获取当前用户以拥有的权限
    @Override
    public List<String> getPermissionList(Object loginId, String loginType) {
        List<String> permission = permissionMapper.selectPermissionByUserId(loginId);
        log.info("用户:[${}],拥有[#{}]权限", loginId, permission);
        return permission;

    }

    @Override
    public List<String> getRoleList(Object loginId, String loginType) {
        return null;
    }
}
